package com.baobao.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */
@IdClass(com.baobao.domain.AddressPK.class)
@Entity
@NamedQueries({
		@NamedQuery(name = "findAddressByBanjiId", query = "select myAddress from Address myAddress where myAddress.banjiId = ?1"),
		@NamedQuery(name = "findAddressByBanjiIdContaining", query = "select myAddress from Address myAddress where myAddress.banjiId like ?1"),
		@NamedQuery(name = "findAddressByImgUrl", query = "select myAddress from Address myAddress where myAddress.imgUrl = ?1"),
		@NamedQuery(name = "findAddressByImgUrlContaining", query = "select myAddress from Address myAddress where myAddress.imgUrl like ?1"),
		@NamedQuery(name = "findAddressByPhone", query = "select myAddress from Address myAddress where myAddress.phone = ?1"),
		@NamedQuery(name = "findAddressByPhoneContaining", query = "select myAddress from Address myAddress where myAddress.phone like ?1"),
		@NamedQuery(name = "findAddressByPrimaryKey", query = "select myAddress from Address myAddress where myAddress.phone = ?1 and myAddress.banjiId = ?2"),
		@NamedQuery(name = "findAllAddresss", query = "select myAddress from Address myAddress") })
@Table(catalog = "baobaodb", name = "address")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "bb/com/baobao/domain", name = "Address")
public class Address implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "phone", length = 40, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String phone;
	/**
	 */

	@Column(name = "banji_id", length = 40, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String banjiId;
	/**
	 */

	@Column(name = "img_url", length = 100)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String imgUrl;

	/**
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 */
	public String getPhone() {
		return this.phone;
	}

	/**
	 */
	public void setBanjiId(String banjiId) {
		this.banjiId = banjiId;
	}

	/**
	 */
	public String getBanjiId() {
		return this.banjiId;
	}

	/**
	 */
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}

	/**
	 */
	public String getImgUrl() {
		return this.imgUrl;
	}

	/**
	 */
	public Address() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Address that) {
		setPhone(that.getPhone());
		setBanjiId(that.getBanjiId());
		setImgUrl(that.getImgUrl());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("phone=[").append(phone).append("] ");
		buffer.append("banjiId=[").append(banjiId).append("] ");
		buffer.append("imgUrl=[").append(imgUrl).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((phone == null) ? 0 : phone.hashCode()));
		result = (int) (prime * result + ((banjiId == null) ? 0 : banjiId.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Address))
			return false;
		Address equalCheck = (Address) obj;
		if ((phone == null && equalCheck.phone != null) || (phone != null && equalCheck.phone == null))
			return false;
		if (phone != null && !phone.equals(equalCheck.phone))
			return false;
		if ((banjiId == null && equalCheck.banjiId != null) || (banjiId != null && equalCheck.banjiId == null))
			return false;
		if (banjiId != null && !banjiId.equals(equalCheck.banjiId))
			return false;
		return true;
	}
}
